package com.guaoran.source.mybatis.v2.execute;

import com.guaoran.source.mybatis.v2.config.Configuration;
import com.guaoran.source.mybatis.v2.mapper.MapperRegistry;
import com.guaoran.source.mybatis.v2.statement.StatementHandler;

import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.List;

/**
 * @author : 孤傲然
 * @Description :
 * @date :2018/5/26 12:42
 */
public class DefaultExecutor implements Executor {
    private Configuration configuration;

    public DefaultExecutor(Configuration configuration) {
        this.configuration = configuration;
    }

    @Override
    public <T> T query(MapperRegistry.KnownMappersInfo knownMappersInfo, Object paramment) throws InvocationTargetException, SQLException, IllegalAccessException, NoSuchMethodException {
        StatementHandler statementHandler = new StatementHandler(configuration);
        return statementHandler.query(knownMappersInfo,paramment);
    }

    @Override
    public <T> List<T> queryList(MapperRegistry.KnownMappersInfo knownMappersInfo, Object paramment) throws InvocationTargetException, SQLException, IllegalAccessException, NoSuchMethodException {
        StatementHandler statementHandler = new StatementHandler(configuration);
        return statementHandler.queryList(knownMappersInfo,paramment);
    }
}
